package com.api;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class PhoenixCodeTest {

    public static void main(String[] args) {
        try {
            Class.forName("org.apache.phoenix.jdbc.PhoenixDriver");
            // 获取连接
            Connection conn = DriverManager.getConnection("jdbc:phoenix:node02,node03,node04:2181");

            String sql = "select * from \"salt_test\"";
            PreparedStatement preps = conn.prepareStatement(sql);

            ResultSet resultSet = preps.executeQuery();

            while (resultSet.next()) {
                String id = resultSet.getString(1);
                String name = resultSet.getString(2);
                String age = resultSet.getString(3);

                System.out.println(id + "---" + name + "----" + age);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
